<extend name="Console:index"/>
<block name="main">

    <!--路径导航-->
        <div>
            <ol class="breadcrumb">
                    <li>电影</li>
            </ol>
        </div>
    <div >
        <div style="float:left">
            <form class="form-search form-inline" method="get" action="{:U('Movie/index')}">
                <input class="form-control" type="text" name="name"  placeholder="名字" value="{$search['name']}"/>
                <input class="form-control" type="text" name="keyword"  placeholder="关键字" value="{$search['keyword']}"/>
                <!-- <input class="form-control" type="text" name="category_id" id="" placeholder="电影分类" value="{$search['category_id']}"/> -->

                <select class="form-control" style="width: 100px" name="columns">
                    <option value=''>所有栏目</option>

                    <foreach name="co" item="vo">

                        <option value="{$key}" <eq name="search.columns" value="$key">selected</eq> >{$key}-{$vo}</option>
                    </foreach>

                </select>

                <select class="form-control" style="width: 100px" name="country_id">
                    <option value=''>所有国家</option>

                    <volist name="country" id="coo">
                        <option value="{$coo.country_id}" <eq name="search.country_id" value="$coo.country_id">selected</eq> >{$coo.name}</option>
                    </volist>

                </select>

                <select class="form-control" style="width: 100px" name="movie_type">
                    <option value=''>所有类型</option>

                    <volist name="movie_type" id="mt">
                        <option value="{$mt.country_id}"  <eq name="search.movie_type" value="$mt.country_id">selected</eq> >{$mt.name}</option>
                    </volist>

                </select>

                <input onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" class="form-control" name="create_time" placeholder="请选择创建日期" value="{$search['create_time']}" >
                <!--<input  class="form-control"type="text" name="title" id="" placeholder="描述" value="{$search['title']}"/>-->
               <span class="btn btn-default btn-sm">
                     <input type="radio" name="st" value="1"   <eq name="search['st']" value="1">checked</eq> /> <span class="h5">启用</span>
                     <input type="radio" name="st" value="2"   <eq name="search['st']" value="2">checked</eq> /><span class="h5">下架</span>
                </span>

                <button class="form-control btn btn-warning" >搜索</button>

            </form>
        </div>


        <div style="float:right">

            <a href="{:U('Movie/add')}" class="btn btn-info">新增电影</a>
            <a href="{:U('Movie/index')}" class="btn btn-primary">全部数据</a>
            <a href="{:U('Movie/delList')}" class="btn btn-default" >回收站</a>
        </div>
        <div style="clear: both"></div>

        <div style="height: 10px"></div>
            <div>

                <table class="table table-bordered ">
                    <tr>
                        <th>序号</th>
                        <th style="width: 50px">id</th>
                        <th style="width: 100px">栏目</th>
                        <th style="width: 150px">类型</th>
                        <th style="width: 150px">名称</th>
                        <th style="width: 150px">标题</th>


                        <th>关键字</th>
                        <th>国家</th>
                        <th>上映年限</th>
                        <th>上映时间</th>
                        <th>关注数</th>
                        <th>分类封面</th>
                        <th>状态</th>
                        <th>排序</th>
                        <th style="width: 200px">时间</th>
                        <th>操作</th>
                    </tr>
                    <volist name="list" id="l" key="k">
                        <tr>
                            <td><input type="checkbox" name="check"  value="{$l.id}"/> {$k}</td>

                            <td>{$l.id}</td>
                            <td>
                                <foreach name="co" item="voo" key="kk">
                                    <eq name="l.columns" value="$kk" >{$voo}</eq>
                                </foreach>

                            </td>
                            <td>
                                <volist name="movie_type" id="mt">
                                    <eq name="l.movie_type" value="$mt.country_id">{$mt.name}</eq>
                                </volist>
                            </td>
                            <td>{$l.name}

                            </td>
                            <td>{$l.title}</td>

                            <td>{$l.search_keywords}</td>
                            <td>
                                <volist name="country" id="coo">
                                     <eq name="l.country_id" value="$coo.country_id">{$coo.name}</eq>
                                </volist>
                            </td>
                            <td><?php echo date('Y',$l['show_time']) ?></td>
                            <td><?php echo date('Y-m-d',$l['play_time']) ?>
                               <br>
                                下架时间：<br>
                                <?php echo date('Y-m-d',$l['end_time']) ?>
                            </td>
                           <td>{$l.collection}</td>
                           <td><a href="{$l.image}"> <img src="{$l.image}" alt="没有上传封面" style="width: 80px"> </a></td>

                            <td>
                                <eq name="l.status" value="1">
                                    <a href="###" class="btn btn-success btn-sm" data-id="{$l.id}" data-type="off" >已启用</a>

                                </eq>

                                <eq name="l.status" value="2">
                                    <a href="###" class="btn btn-danger btn-sm" data-id="{$l.id}" data-type="on" >已下架</a>

                                </eq>
                                <eq name="l.status" value="3">
                                    已删除
                                </eq>
                            </td>
                            <td>{$l.sort}</td>

                            <td>创建时间:<br><?php echo date('Y-m-d H:i:s',$l['create_time']); ?><br>
                                最近修改:<br><?php echo date('Y-m-d H:i:s',$l['last_update_time']); ?>
                            </td>
                            <td>
                                <a href="{:U('Movie/edit',array('id'=>$l['id']))}" class="btn btn-warning">编辑</a><br>
                              <!--  <a href="{:U('Movie/editPicture',array('id'=>$l['id']))}" class="btn btn-warning">更换封面图片</a>-->
                              <a href="{:U('MovieLevel2/index',array('movie_id'=>$l['id']))}" class="btn btn-danger">管理二级目录 <span class="badge">{$l.count}</span></a><br>
                              <!--<a href="{:U('MovieShuffling/index',array('movie_id'=>$l['id']))}" class="btn btn-info">管理轮播图 </a>-->
                            </td>
                        </tr>
                    </volist>

                    <tr>
                        <td><input type="checkbox" name="" id="allChecked"/>ALL</td>
                        <td colspan="13" >
                            <div >
                                <a href="#" class="btn btn-warning btn-sm" id="btn_on">启用</a>
                                <a href="#" class="btn btn-danger btn-sm" id="btn_off">下架</a>
                                <a href="#" class="btn btn-danger btn-default" id="btn_del">删除</a>
                                <a href="{:U('Movie/add')}" class="btn btn-info">新增电影</a>
                            </div>

                        </td>
                    </tr>

                 </table>
            </div>
            <div class="text-center">
               {$page}
            </div>
        </div>

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script>
        $(function(){
            //选择了的数据集合
            function allchecked()
            {
                var checked = '';
                $("input[name='check']:checked").each(function () {
                    checked += $(this).prop('value') + ',';
                });
                return checked;
            }

            //全选/全不选
            $('#allChecked').click(function(){
                if ($("#allChecked").prop("checked")) {
                    $(":checkbox").prop("checked", true);
                } else {
                    $(":checkbox").prop("checked", false);
                }
            });

            //更改状态的函

            function alter(type,ids)
            {
                var t = type;
                var idlsit;
                if(ids){
                    idlist = ids;
                }else{
                    idlist = allchecked();
                }

                $.post('{:U("Movie/alter")}',{'idlist':idlist,'type':t},function(data){
                    alert(data.mes);
                    window.location.reload();
                });
            }


            //启用
            $('#btn_on').click(function(){if(confirm('你确定要对进行  "启用"  操作吗?')) alter('on');});
            //下架
            $('#btn_off').click(function(){if(confirm('你确定要对进行  "下架"  操作吗?')) alter('off');});
            $('#btn_del').click(function(){if(confirm('你确定要对进行  "删除"  操作吗?')) alter('del');});

            $("[href='###']").click(function(){
                var id = $(this).attr('data-id');
                var type = $(this).attr('data-type');
                var strType;
                if( type =='on' ){
                    strType = '启用';
                }
                if( type == 'off'){
                    strType = '下架';
                }
                if( type == 'del'){
                    strType = '删除';
                }

                if(confirm('你确定要对进行  '+strType+'  操作吗?')){
                    alter(type,id);
                }

            })

        });


    </script>

</block>
